#include<stdio.h>
#include<assert.h>
#include<unistd.h>
#include<sys/wait.h>
int main(){
	pid_t id = fork();
	assert(id >=0);
	if(!id){
		printf("my child my id:%d\n",getpid());
		char*const _argv []={"ls","-a","-l","--color=auto",NULL};
		execv("/usr/bin/ls",_argv);
		perror("error");
	}
	int status = 0;
	pid_t ret = waitpid(id,&status,0);
	assert(ret>= 0);
	if(WIFEXITED(status)){
		printf("child work success id:%d exit_code:%d\n",ret,WEXITSTATUS(status));
	} 
	else{
		printf("child work error!!\n");
	}
}
